package com.ngkj.zmfptback.sys.config;

import lombok.Data;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * @author ChenHN
 * @since 2021/12/1 creation
 **/
@Data
@Component
public class JwtConfig {

    /**
     * 密钥
     */

    public static String secret;

    /**
     * TokenKEY
     */

    public static String tokenHeader;

    /**
     * token前缀
     */
    public static String tokenPrefix;

    /**
     * 过期时长
     */
    public static Integer expiration;

    /**
     * 不需要认证的接口
     */
    public static String antMatchers;

    @Value("${jwt.secret}")
    public  void setSecret(String secret) {
        JwtConfig.secret = secret;
    }

    @Value("${jwt.tokenHeader}")
    public  void setTokenHeader(String tokenHeader) {
        JwtConfig.tokenHeader = tokenHeader;
    }

    @Value("${jwt.tokenPrefix}")
    public  void setTokenPrefix(String tokenPrefix) {
        JwtConfig.tokenPrefix = tokenPrefix;
    }

    @Value("${jwt.antMatchers}")
    public  void setAntMatchers(String antMatchers) {
        JwtConfig.antMatchers = antMatchers;
    }

    @Value("${jwt.expiration}")
    public void setExpiration(Integer expiration) {
        JwtConfig.expiration = expiration * 1000;
    }
}
